home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 7 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  50 lines

  1. Path: in2.uu.net!bounce-back
  2. Date: 05 Jan 96 06:25:10 GMT
  3. Approved: fjh@cs.mu.oz.au
  4. From: jamshid@io.com (Jamshid Afshar)
  5. Newsgroups: comp.std.c++
  6. Subject: Overloaded template functions
  7. X-Original-Date: 4 Jan 1996 22:34:08 -0600
  8. Organization: Illuminati Online, Austin, Texas, USA
  9. Message-ID: <4ci9o0$l4o@bermuda.io.com>
  10. Summary: am I expecting too much from C++ or VC++?
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMOzEYuEDnX0m9pzZAQGP4gF/XVbgXSKJv3OZmiiYQ58uL71d+E7LNmog
  13.     qbF3UJ951xpfo3AQbOWgnlYgMt0VK6Mw
  14.     =P6ea
  15.  
  16. Hi, folks, long time no see.  I'm just wondering if the standard
  17. actually disallows some code of mine containing overloaded function
  18. templates.  Fortunately (for my code, bad for me) I think this is just
  19. another VC++ 4 bug wrt templates.  Oh well, at least VC++ has improved
  20. to the point that it handles *most* of the stuff I wrote three years
  21. ago under BC++ 3.1.
  22.  
  23. cl -c bug2.cpp
  24. Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 10.00.5270 for 80x86
  25. bug2.cpp(16) : error C2668: 'functor' : ambiguous call to overloaded function
  26. (new behavior; please see help)
  27.  
  28.    template<class O, class R>
  29. void functor(O* object, R (O::*method)());
  30.  
  31.    template<class O, class R, class P>
  32. void functor(O* object, R (O::*method)(P));
  33.  
  34. class M {
  35. public:
  36.     int f( char* );
  37.     int g( );
  38. };
  39.  
  40. int main() {
  41.     M m;
  42.     functor(&m, &M::f);
  43.     functor(&m, &M::g);  // VC++ 4 incorrectly flags this as ambiguous
  44.     return 0;
  45. }
  46. ---
  47. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  48.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  49.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  50.